package org.darcy.youchat.activity.message;

import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;

import org.darcy.youchat.R;
import org.darcy.youchat.activity.BaseActivity;
import org.darcy.youchat.databinding.ActivityTransferBinding;

/**
 * 4.转账
 */
public class TransferActivity extends BaseActivity {

    private ActivityTransferBinding binding;

    @Override
    public void initView() {
        binding = ActivityTransferBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setSupportActionBar(binding.mToolbar.toolbar);
        String titleName = "转账";
        getSupportActionBar().setTitle(titleName);
        getSupportActionBar().setSubtitle("微信安全支付");
        binding.mToolbar.toolbar.setNavigationIcon(R.mipmap.ic_back);
    }

    @Override
    public void initListener() {
        binding.etMoney.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (s.length() > 12) {
                    binding.etMoney.setText(s.subSequence(0, 12));
                    binding.etMoney.setSelection(12);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }



}
